<template>
	<view>
		<!-- 公司信息 -->
		<uni-nav-bar :border="false">
			<block slot="left">
				<!-- <image class="back-img" src="../../../static/index.jpg" mode="widthFix" @click="go_back()"></image>
				<image class="right-img" src="../../../static/add.png" mode="" @click="toAdd()"></image> -->
			</block>
		</uni-nav-bar>
		<view class="company_info">
			<mescroll-uni refs="mescroll" @getData="getData">
				<block slot="list">
					<block v-if="dataList.length">
					<view class="company_info-base ns-border-color-gray" v-for="(item,index) in dataList" :key="index">
						<view class="img"><image :src="item.headimg ? $util.img(item.headimg) : $util.getDefaultImage().default_headimg" mode="aspectFit"></image></view>
						<view class="flex"  @click="toDetail(item.member_id)">
							<view class="company_name ns-font-size-lg">
								<view class="t1">{{item.username}}</view>
								<view class="t2 ns-text-color-gray">{{item.nickname}}<view class="remark">（邀请码：{{ item.invite_code }}）</view></view>
							</view>
							<view class="time ns-font-size-sm ns-text-color-gray-lighten">{{ $util.timeStampTurnTime(item.reg_time)}}</view>
						</view>
					</view>
					</block>
					<block v-else><ns-empty text="暂无数据" :isIndex="!1"></ns-empty></block>
				</block>
				
			</mescroll-uni>
			<!-- #ifdef MP -->
			<view class="confirm-btn" @click="addFun"><view>添加</view></view>
			<!-- #endif -->
			<view class="add_son_list" @click="toAdd()">
				+
			</view>
			
		</view>
		
	</view>
</template>

<script>
	


export default {
	data() {
		return {
			dataList: [],
			mescroll: null
		};
	},
	onShow() {
		// this.teamOrganizationAndMember = uni.getStorageSync('teamOrganizationAndMember')
		// console.log(this.teamOrganizationAndMember)
	},
	// onNavigationBarButtonTap() {
	// 	this.$util.allowAddGo('ADDON_YUNCHUANG_AGENT_MEMBER_INVITE','/otherpages/agent/my_member_edit/my_member_edit');
	// },
	onLoad(option) {
	},
	methods: {
		toDetail(e){
			//console.log(e);
			this.$util.redirectTo("/otherpages/member/bussiness_user/add?member_id="+e);
		},
		//添加用户
		toAdd() {
			this.$util.redirectTo("/otherpages/member/bussiness_user/add");
		},
		go_back(){					
			uni.navigateBack({
				url: '/pages/member/index/index',
			})
		},
		// addFun(){
		// 	this.$util.allowAddGo('ADDON_YUNCHUANG_AGENT_MEMBER_INVITE','/otherpages/agent/my_member_edit/my_member_edit');
		// },
		getData(mescroll) {
			this.mescroll = mescroll;
			// if(!this.$util.isAllow('ADDON_YUNCHUANG_AGENT_MEMBER_LIST')){
			// 	this.$util.showToast({title:'暂无权限'});
			// 	mescroll.endErr();
			// 	if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
			// 	return;
			// }
			this.$api.sendRequest({
				url: '/api/member/getChildAccount',
				data: {
					page_size: mescroll.size,
					page: mescroll.num
				},
				success: res => {
					let newArr = []
		
					let msg = res.message;
					if (res.code == 0 && res.data) {
						newArr = res.data.list;
					} else {
						this.$util.showToast({
							title: msg
						})
					}
					mescroll.endSuccess(newArr.length);
					//设置列表数据
					if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(newArr); //追加新数据
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				},
				fail: res => {
					mescroll.endErr();
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		}
	}
};
</script>

<style lang="scss">
@import '@/otherpages/member/bussiness_user/public/css/classification.scss';



.add_son_list {
	position: absolute;
	right: 40rpx;
	bottom: 40rpx;
	width: 100rpx;
	line-height: 100rpx;
	height: 100rpx;
	background-color: #ff464a;
	text-align: center;
	border-radius: 50rpx;
	box-shadow: 0 0 10rpx #ccc;
	color: white;
	font-size: 48rpx;
	z-index: 99999 !important;
}

/deep/.mescroll-uni-fixed {
	position: relative;
	top: 0 !important;
	height: 100% !important;
}

.back-img {
		width: 20rpx;
		height: 20rpx;
		margin-left: 20rpx;
}
	
.right-img{
	position: absolute;
	width: 35rpx;
	height: 35rpx;
	right: 30rpx;
	top: 30rpx;
}


/* #ifdef MP */
.confirm-btn {
	width: 100%;
	height: 144rpx;
	background-color: #fff;
	view {
		width: 90%;
		height: 80rpx;
		border-radius: $ns-border-radius;
		background-color: #ff464a;
		line-height: 80rpx;
		color: #fff;
		text-align: center;
		margin-top: 20rpx;
	}
	display: flex;
	z-index: 8;
	justify-content: center;
	position: fixed;
	bottom: 0;
}
.btn-zw-bar {
	height: 144rpx;
}
/* #endif */

.company_info {
	  height: calc(100vh - 44px - 60rpx);
	.company_info-base {
		padding-right: 0;
		padding-left: 0;
		margin-left: 30rpx;
		border-bottom: 1px solid;
		.flex {
			position: relative;
			flex: 1;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-right: 30rpx;
			.company_name{
				.t2{
					.remark{
						display: inline;
						font-size:22rpx;
						padding-left:12rpx;
					}
				}
			}
		}

		.flex::after {
			content: '';
			position: absolute;
			border-bottom: 1px solid #eee;
			width: 100%;
			bottom: -36rpx;
		}
		.flex:last-child::after {
			border-bottom: 0;
		}
		.img {
			height: 90rpx;
			width: 90rpx;
		}
	}
}

.flex-list .flex-item .flex-right .flex-text .iconfont {
	font-weight: bold;
}
.company_info .company_info-base .img{width:80rpx;height:80rpx}
.time{align-self: flex-start;height:50rpx;line-height: 50rpx;color:#8F95AD}
</style>
